//
// Created by 王书哲 on 25-3-15.
//
#include <stdio.h>
#include <string.h>
char * s_gets(char *, int);
int main(void)
{
    char first[40];
    printf("Enter a code:\n");
    s_gets(first, 40);
    puts(first);
    return 0;
}

char * s_gets(char * st, int n)
{
    char * ret_val;
    int i = 0;
    ret_val = fgets(st, n, stdin);
    if (ret_val)
    {
        char * n = strchr(st, '\n');
        if (n)
            n = '\0';
        else
            while (getchar() != '\n')
                continue;
    }
    return ret_val;
}